#ifndef VTreeView_H
#define VTreeView_H

#include "VSettings.h"
#include "VTreeModel.h"
#include "VItemDelegate.h"

///////////////////////////////////////////////////////////////////////////////
class VTreeView;
///////////////////////////////////////////////////////////////////////////////

class VTreeViewActions : public QObject
{
	Q_OBJECT

public:
	VTreeViewActions(VTreeView *view);
	~VTreeViewActions();

	QToolBar *toolBar() const { return m_toolbar;}

	void update();

private:
	VTreeView *m_view;
	QToolBar *m_toolbar;
	QAction* m_insertChildNode;
	QAction* m_insertNodeBefore;
	QAction* m_insertNodeAfter;
	QAction* m_deleteNode;
	QAction* m_edit;
};

///////////////////////////////////////////////////////////////////////////////
															
class VTreeView : public QObject
{
	Q_OBJECT
	
public:
	VTreeView(QObject *parent = 0);
	~VTreeView();
	
	QTreeView *view() const { return m_view;}
	QSortFilterProxyModel *proxyModel() const { return m_proxyModel;}
	VTreeViewActions &actions() { return m_actions;}
	
	void setTreeModel(VTreeModel *treeModel);
	
public slots:	
	void rowChanged(const QModelIndex &index);
	void edit();
	void insertChildNode();
	void insertNodeBefore();
	void insertNodeAfter();
	void deleteNode();
	
private:
	QTreeView *m_view;
	VTreeModel *m_treeModel;
	QSortFilterProxyModel *m_proxyModel;
	VTreeViewActions m_actions;
	friend VTreeViewActions;
};

///////////////////////////////////////////////////////////////////////////////

#endif
